package com.yanqu.road.server.cmd.player;

import com.yanqu.road.pb.player.BlacklistProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.CrossProtocol;

/**
 * @author ：zfr
 * @date ：2021/4/6 17:34
 */
@Cmd(code = CrossProtocol.C_CROSS_ADD_BLACK_LIST_GET_USER_INFO, desc = "拉黑到跨服获取玩家信息")
public class CrossAddBlackListCmd extends CrossCommand {
    private long blackUserId;
    private long blackUserServerId;
    private int type;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        BlacklistProto.BlacklistAddCrossReqMsg reqMsg = BlacklistProto.BlacklistAddCrossReqMsg.parseFrom(packet.getBytes());
        blackUserId = reqMsg.getUserId();
        blackUserServerId = reqMsg.getServerId();
        type = reqMsg.getType();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        BlacklistProto.BlacklistAddCrossReqMsg.Builder reqMsg = BlacklistProto.BlacklistAddCrossReqMsg.newBuilder();
        reqMsg.setUserId(packet.getPlayerId());
        reqMsg.setServerId(serverId);
        reqMsg.setType(type);
        YanQuMessage yqMsg = YanQuMessageUtils.buildMessage(Protocol.S_BLACKLIST_GET_USER_INFO_CROSS, reqMsg);
        MessageHelper.sendPacket(blackUserServerId, blackUserId, yqMsg);
    }

    @Override
    public void sendData() {

    }
}
